fix(windows-ime): TSF 插入后输入法未切回原输入法(#852) - #914
Merged
Conversation
- restore_decision 改为依据会话已知的激活状态(openless_was_activated / activation_failed),不再依赖 GetActiveProfile 探测结果,避免后台线程误判导致跳过恢复 - restore_profile 中 legacy 失败不再短路现代 ActivateProfile,任一成功即视为整体成功 - restore_session 增加恢复后校验与一次重试;saved 本身是 OpenLess 时跳过(粘滞态防护) - prepare/restore 补充诊断日志,便于区分未走恢复/恢复被跳过/恢复失败
Contributor
PR Reviewer Guide 🔍(Review updated until commit dbaea91)Here are some key observations to aid the review process:
|
H-Chris233
marked this pull request as ready for review
August 4, 2026 11:29
Contributor
|
Persistent review updated to latest commit 2178958 |
- restore_profile 合并 TextService/KeyboardLayout 同形分支,差异收敛为参数 - 恢复重试等待在 tokio runtime 上改用 block_in_place 让出工作线程 - 粘滞防护/校验/重试抽为 run_restore_flow,可跨平台注入测试 - 新增 5 个恢复流程测试(粘滞跳过/一次成功/重试/restore 报错仍校验/探测报错)
Contributor
|
Persistent review updated to latest commit 49dbd0b |
- run_restore_flow 重试条件改为 restore_profile 返回值(legacy+modern 均失败才重试) - is_openless_profile_active 探测降级为恢复后诊断日志,不再参与控制流(线程局限见 Open-Less#852) - 更新恢复流程测试覆盖新语义(6 个用例,47/47 通过)
Contributor
|
Persistent review updated to latest commit dbaea91 |
- 新增 windows_ime_restore 模块:run_restore_flow/RestoreOutcome/重试等待 迁出 windows_ime_session;sleep_restore_retry 增加 MultiThread runtime 守卫 - report_restore_step_results 提升为无门控顶层函数,测试可在任意平台执行 - restore_profile 参数收敛为 RestoreArgs 结构体(resolve_restore_args) - 测试夹具 openless_snapshot_for_test 由生产常量派生,替换重复 GUID 字面量 - restore_session 消费 RestoreOutcome 补 debug 诊断日志 - backend-tests 纳入 windows_ime_profile/windows_ime_restore(tokio/winreg/features) - 新增 9 个单测现已在 macOS/Linux cargo test --lib 与 Windows backend-tests 执行
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
背景
Windows 11 以 TSF 输入法为插入模式时,听写结束(录音结束)后输入法停在 OpenLess,没有切回用户原输入法(issue #852)。
根因
estore_profile 中 legacy 两步失败会用 ? 短路,导致现代 ActivateProfile 根本不执行,恢复整体失败。
改动
estore_decision 改为依据会话已知的激活状态(openless_was_activated / ^Gctivation_failed)决定恢复,不再依赖探测结果。
estore_profile 中 legacy 与现代调用各自独立执行并分别记录结果;任一成功即视为整体成功,两者都失败才算失败。
restore_session 以 restore_profile 返回值判定成败(legacy 与现代均失败才算失败),失败后 250ms 重试一次;恢复后探测(GetActiveProfile)仅作诊断日志,不参与控制流。
estore_session 增加诊断日志(决策依据、恢复前 active profile、恢复结果),便于区分“未走恢复 / 恢复被跳过 / 恢复失败”。
已知限制
测试
eport_restore_step_results 用例与更新的
estore_decision 用例)。
closes #852
PR Type
Bug fix, Tests
Description
Fix IME restore relying on session activation
Legacy and modern restores independent; any success passes
Sticky-state guard, retry, and diagnostic logging
Cross-platform restore module with unit tests
Diagram Walkthrough
File Walkthrough
backend_rust.rs
Add new IME modules to backend testsopenless-all/app/src-tauri/backend-tests/tests/backend_rust.rs
windows_ime_profileandwindows_ime_restoremodules in backendtest harness
lib.rs
Register windows_ime_restore moduleopenless-all/app/src-tauri/src/lib.rs
windows_ime_restoremodulewindows_ime_restore.rs
Create cross-platform restore flow moduleopenless-all/app/src-tauri/src/windows_ime_restore.rs
run_restore_flowwith sticky guard, retry, anddiagnostic verification
RestoreOutcomeenum and retry delay constantsleep_restore_retrythat avoids blocking tokio workerthreads
scenarios
windows_ime_profile.rs
Make restore decision session-based and restore paths independentopenless-all/app/src-tauri/src/windows_ime_profile.rs
is_openless_profile_snapshothelper for sticky-state detectionrestore_decisionto rely on session activation facts instead ofbackground-thread probe
report_restore_step_resultsandresolve_restore_argsforindependent legacy/modern restore execution
windows_ime_session.rs
Use session facts and restore flow for IME restoreopenless-all/app/src-tauri/src/windows_ime_session.rs
restore_sessionto userun_restore_flowand session activationfacts
restore_decisionbased onconfirmed activation state
Cargo.toml
Add dependencies for IME restore testsopenless-all/app/src-tauri/backend-tests/Cargo.toml
tokiowith multi-thread runtime feature for testing retry delayswinregdependency required by IMErestore tests